public class MileageLogic {
  static final Integer MAX_MILES_PER_DAY = 500;
  
  public boolean areMilesAllowed(Double miles) {
  	String createdbyId = UserInfo.getUserId();
  	Mileage__c[] mileageList = [select miles__c from Mileage__c where createddate = TODAY AND createdbyid = :createdbyId];
    Double totalmiles = miles;
    for(Mileage__c mileage: mileageList) {
      totalmiles += mileage.miles__c;
    }

    return totalmiles < MAX_MILES_PER_DAY;
  }
}